var signin = {
    vueInfo: null,
    URL: {
        getUserQRCodeUrl: "/api/signin/getUserByQRCode",
        signinUrl: "/api/signin/signin",
    },
    detail: {
        getUserQRCode: function () {
            var signinType = "";
            $.post(signin.URL.getUserQRCodeUrl, {qrcode: __JsUtil.GetQuery("qrcode")}, function (data) {
                if (!data.hasError) {
                    signin.vueInfo = new Vue({
                        el: "#all",
                        data: {
                            userInfo: data.object,
                        },
                        mounted: function () {
                            winInit();
                            $.pop.load(false, null);
                        },
                        methods: {
                            signin: function () {
                                var vmObj = this;
                                signin.detail.signin(vmObj);
                            }
                        },
                        filters: {
                            sexFilter: function (value) {
                                if (value == 1) {
                                    return "男";
                                } else {
                                    return "女";
                                }
                            },
                            levelStr: function (value) {
                                if (value == 1) {
                                    return "普通 580";
                                } else if (value == 2) {
                                    return "普通 880";
                                } else if (value == 3) {
                                    return "VIP 1380";
                                } else if (value == 4) {
                                    return "VIP 1680";
                                }
                            },
                            forumNumStr: function (value) {
                                if (value == 1) {
                                    return "中国智造，领航全球";
                                } else if (value == 2) {
                                    return "电商新视界";
                                } else if (value == 3) {
                                    return "玩转采购节";
                                } else {
                                    return "";
                                }
                            },
                            signinTypeStr: function (value) {
                                if (value == 1) {
                                    return "已签到";
                                } else {
                                    return "签到确认";
                                }
                            },
                            isSingleStr:function (value) {
                                if (value == 0){
                                    return "否";
                                }else if (value == 1){
                                    return "是";
                                }else {
                                    return "";
                                }
                            }
                        }
                    });
                } else {
                    $.pop.tips(data.error);
                    if (data.errType != null) {
                        if (data.errType == "NOSESSION") {
                            setTimeout(function () {
                                window.location.href = data.errUrl;
                                return false;
                            }, 400);
                        }
                    }
                }
            }, "json").error(function (XMLHttpRequest, textStatus, errorThrown) {
                $.pop.load(false, null);
                $.pop.tips("系统繁忙，请稍后" + XMLHttpRequest.status + "," + XMLHttpRequest.readyState + "," + textStatus);
            });
        },
        signin: function (vmObj) {
            var opts = {
                left: {
                    text: "确认",
                    call: function () {
                        $.pop.load(true, "正在提交...");
                        $.post(signin.URL.signinUrl, {qrcode: vmObj.userInfo.qrcode, id: vmObj.userInfo.id}, function (data) {
                            $.pop.load(false, null);
                            if (!data.hasError) {
                                $.pop.tips(data.error);
                                setTimeout(function () {
                                    window.location.reload()
                                    return false;
                                }, 400);
                            } else {
                                $.pop.tips(data.error);
                                if (data.errType != null) {
                                    if (data.errType == "NOSESSION") {
                                        setTimeout(function () {
                                            window.location.href = data.errUrl;
                                            return false;
                                        }, 400);
                                    }
                                }
                            }
                        }, "json").error(function (XMLHttpRequest, textStatus, errorThrown) {
                            $.pop.load(false, null);
                            $.pop.tips("系统繁忙，请稍后" + XMLHttpRequest.status + "," + XMLHttpRequest.readyState + "," + textStatus);
                        });
                    }
                },
                rite: {
                    text: "取消"
                },
                text: "确认要签到吗？"
            };
            $.pop.chio(opts);
        }
    }
}